package com.kantboot.system.user.web.controller;

import com.kantboot.system.user.domain.entity.SysPermission;
import com.kantboot.system.user.service.ISysPermissionService;
import com.kantboot.util.common.result.RestResult;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/system-user-web/permission")
public class SysPermissionController {

    @Resource
    private ISysPermissionService service;

    @PostMapping("/getByUserId")
    public RestResult<List<SysPermission>> getByUserId(@RequestParam("userId") Long userId) {
        return RestResult.success(service.getByUserId(userId),"getSuccess","获取成功");
    }

    @PostMapping("/getByRoleCode")
    public RestResult<List<SysPermission>> getByRoleCode(@RequestParam("roleCode") String roleCode) {
        return RestResult.success(service.getByRoleCode(roleCode),"getSuccess","获取成功");
    }

    /**
     * 获取自身的权限
     */
    @PostMapping("/getSelf")
    public RestResult<List<SysPermission>> getSelf() {
        return RestResult.success(service.getSelf(),"getSuccess","获取成功");
    }

}
